﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class AspNetPaper分页_ListPage : System.Web.UI.Page
{
    string sql;
    //Tong.TongUse  TextData= new Tong.TongUse();
     
    
    
   
    protected void Page_Load(object sender, EventArgs e)
    {
        //url分页要加的东东
        if (!IsPostBack)
        {
            BindData();
        }


    }

    void BindData()
    {
            GridView1.DataSource = FyNetPager(AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"select * from [test]");
            GridView1.DataBind();
            AspNetPager1.RecordCount = 10095;

    }
    

    /// <summary>
    /// AspNetPage 分页数据源 返回 填充表 "FyNetPager" 的 DataSet
    /// </summary>
    /// <param name="CruuShu">当前记录条数  AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1)</param>
    /// <param name="PageSize">每页显示条数 AspNetPager1.PageSize</param>
    /// <returns></returns>
    public DataSet FyNetPager(int CruuShu,int PageSize,string sql)
    {
        string Connstr = "Provider=MicroSoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("../App_Data/db1.mdb");//联接字符串
        OleDbConnection MyConn = new OleDbConnection(Connstr);

        OleDbDataAdapter NetPagerDa = new OleDbDataAdapter(sql,MyConn);
        NetPagerDa.SelectCommand.CommandType = CommandType.Text;//选择执行命令的方式
        DataSet MyDs = new DataSet();

        NetPagerDa.Fill(MyDs,CruuShu,PageSize,"FyNetPager");
        NetPagerDa=null;

        return MyDs;

    }

    /// <summary>
    /// url 分页要加的东东
    /// </summary>
    /// <param name="src"></param>
    /// <param name="e"></param>
    protected void AspNetPager1_PageChanged(object src, EventArgs e)
    {
        BindData();
    }


}
